home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Developer Kit / QuickTime 2.0 Developer Kit.iso / mac / MAC / Programming Stuff / Documentation / develop / develop Issue 20 / develop 20 code / QTTextSample / TextMediaExample.h < prev    next >
Encoding:
Text File  |  1994-10-14  |  4.5 KB  |  150 lines  |  [TEXT/MPCC]

  1. // This is based on the sample code on the QuickTime 1.5 CD ROM
  2. //
  3. //     sample to show how to do searches with text media, and how to use
  4. // a simple text proc to get the text (without the style info) out and
  5. // to display it in a window.
  6. //
  7. //    Copyright:    © 1992-4 by Apple Computer, Inc.
  8. // 
  9. // Modifications by Nick Thompson, 16 May 1994
  10. //        5/16/94        nt        added text media stuff, repeat text in box below movie, uses TextBox
  11. //        5/17/94        nt        implement find dialog
  12. //         5/31/94        nt        implement textedit stuff to allow editing of the text track
  13. //        6/1/94        nt        clean up textedit stuff and allow user to edit the text track
  14. //        10/8/94        nt        support for styled text, bug fixes
  15. //
  16. // to do:
  17. //        fix up cut and paste for text edit commands
  18. //        TE edit menu
  19.  
  20.  
  21. #ifndef _TEXTMEDIAEXAMPLE_
  22. #define _TEXTMEDIAEXAMPLE_
  23.  
  24. #define HiWrd(aLong)    (((aLong) >> 16) & 0xFFFF)
  25. #define LoWrd(aLong)    ((aLong) & 0xFFFF)
  26.  
  27.  
  28. //---------------------------------------------------------------------------
  29. // define a record to hold the information we need for each movie window.
  30. // The movie can be gotten from the movieController, and we need the TE and
  31. // control stuff for the edit area
  32. //---------------------------------------------------------------------------
  33.  
  34. typedef    struct    {
  35.     MovieController        myController ;
  36.     TEHandle            myTEH ;
  37.     ControlHandle        myFindButton ;                // this is the find button for this window
  38.     ControlHandle        myUpdateButton ;            // lets the user update the text they just typed in
  39.     Boolean                myMovieIsActive ;            // either the movie is or the te field is.
  40.     Boolean                myTextHasBeenModified ;        // did the user change the text for the track
  41. } DocumentRecord, *DocumentPtr, **DocumentHandle ;
  42.  
  43. //---------------------------------------------------------------------------
  44.  
  45.  
  46. extern const        RGBColor    kWindowBGColor ;    // grays made the caret yellow, ughh, need to investigate this
  47. extern const         RGBColor    kRGBBlack ;
  48. extern const         RGBColor     kRGBGray ;
  49. extern const         RGBColor    kRGBWhite ;
  50. extern const        short        kSlopMargin ;
  51. extern const        Rect        kDefaultWinRect ;
  52.  
  53.  
  54. //---------------------------------------------------------------------
  55. // items in the find dialog
  56. //
  57. // This dialog is posted to allow the user to search for text in the 
  58. // movie's text track
  59. //---------------------------------------------------------------------
  60.  
  61. enum {
  62.     diOK = 1,
  63.     diCancel,
  64.     diTextBox,
  65.     diTextTitle,
  66.     diBackwardsCheckBox,
  67.     diWrapCheckBox
  68. } ;
  69.  
  70.  
  71. // make these globals, they contain state info for the find dialog
  72.  
  73. extern    Boolean        gDlgSearchBack ;
  74. extern    Boolean        gDlgSearchWrap ;
  75. extern    Str255        gDlgSearchText ;
  76.  
  77. //---------------------------------------------------------------------
  78. //
  79. // menus and items...
  80.  
  81. enum {
  82.     mApple = 128,
  83.     mFile,
  84.     mEdit
  85. } ;
  86.  
  87. enum {
  88.     iAbout = 1
  89. } ;
  90. enum {
  91.     iOpen = 1,
  92.     iClose,
  93.     iUnused1,
  94.     iSaveAs = 4,
  95.     iUnused2,
  96.     iQuit
  97.     
  98. } ;
  99.  
  100. enum {
  101.     iUndo = 1,
  102.     iCut = 3,
  103.     iCopy,
  104.     iPaste,
  105.     iClear,
  106.     iSelectAll = 8
  107. } ;
  108.  
  109. //---------------------------------------------------------------------
  110.  
  111. DocumentHandle        CreateDocumentHandle( WindowPtr    aWindow ) ;
  112. WindowPtr    CreateMovieWindow( Rect *aRect, Str255 theTitle ) ; 
  113. MovieController    SetUpMovieWindowWithController( WindowPtr    aWindow, Movie aMovie ) ; 
  114. OSErr SetMovieTextHandler( WindowPtr aWindow ) ;
  115. OSErr    AddTEAndControl( WindowPtr    aWindow ) ; 
  116. void    DoCreateMovieWindow( Movie aMovie) ; 
  117. void    DoDestroyMovieWindow( WindowPtr aWindow ) ;
  118. void    DoUpdateText( WindowPtr whichWindow, Point theMouse, ControlHandle aControl ) ; 
  119. void    HandleContentClick( WindowPtr whichWindow, EventRecord *theEvent ) ;
  120. void    MyDoIdle( WindowPtr whichWindow ) ; 
  121. void    DoActivateWindow( WindowPtr    whichWindow, Boolean becomingActive) ; 
  122. void     DoSelectActive( WindowPtr whichWindow ) ; 
  123. void    AdornWindow( WindowPtr whichWindow, const RGBColor *adornerColor ) ;
  124. void    DoUpdateWindow( WindowPtr whichWindow ) ;
  125. void     MainEventLoop( void ) ; 
  126. Boolean IsAppWindow(WindowPtr window) ;
  127. void     DoFindDialog( WindowPtr theMovieWindow, Point theMouse, ControlHandle aControl ) ; 
  128. void     DoSearchForStringInMovieWindow(    WindowPtr theMovieWindow, 
  129.                                         Str255 SearchText, 
  130.                                         Boolean searchBack,
  131.                                         Boolean searchWrap) ; 
  132. void     AdjustMenus( void ) ; 
  133. void     HandleKeyPress(EventRecord *event) ;
  134. void     HandleMenuCommand(long menuResult) ;
  135. void     InitMac( void ) ;
  136. void     DoDrawCurrentText( WindowPtr theWindow ) ;
  137.  
  138. pascal OSErr MyTextProc(    Handle         thisText, 
  139.                             Movie         thisMovie, 
  140.                             short         *displayFlag,
  141.                             long         refcon) ;            // contains a ref to the window for this movie
  142. void     main (void) ;
  143.  
  144.  
  145. // command handlers
  146.  
  147. OSErr HandlePrintDoc( FSSpec *myFSS ) ;
  148. OSErr HandleOpenDoc( FSSpec *myFSS ) ;
  149.  
  150. #endif